package com.copote.vmp.basedata.feign.factory;

import com.copote.vmp.basedata.feign.BasedataAPI;
import com.copote.vmp.basedata.model.Result;
import com.copote.vmp.basedata.model.entity.VehicleInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class BasedataAPIFallbackFactory implements FallbackFactory<BasedataAPI> {
    @Override
    public BasedataAPI create(Throwable cause) {
        log.error("异常原因:{}", cause.getMessage(), cause);
        return new BasedataAPI() {

            @Override
            public Result<VehicleInfo> getVehicleInfo(String id) {
                return Result.error("远程接口调用异常");
            }

            @Override
            public Result<?> saveVehicleInfo(VehicleInfo vehicleInfo) {
                return Result.error("远程接口调用异常");
            }
        };
    }
}
